home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
426-450
/
disk_438
/
gadgeted
/
source
/
km_handler.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
8KB
|
197 lines
/*----------------------------------------------------------------------*
km_handler.c Version 2.0 © Copyright 1990 Jaba Development
Author : Jan van den Baard
Purpose: handling of menu and keyboard events
*----------------------------------------------------------------------*/
extern struct Menu Titles[];
extern struct Screen *MainScreen;
extern struct Window *MainWindow;
extern struct RastPort *MainRP;
extern struct GadgetList Gadgets;
extern USHORT FrontPen, BackPen, GadgetCount, BackFill;
extern BOOL Saved, REQUESTER, WORKBENCH, WBSCREEN;
extern UBYTE wbb[20];
/*
* quit if the anwser is yes
*/
VOID quit()
{
BOOL Quit = FALSE;
if(Saved == FALSE)
{ if(Ask("Your work isn't saved !","Quit anyway ?") == TRUE)
Quit = TRUE;
}
else
{ if(Ask("Are you sure you","want to Quit ?") == TRUE)
Quit = TRUE;
}
if(Quit == TRUE) close_up(NULL);
}
/*
* handle the menu events (drag selections possible)
*/
VOID handle_menus(menu_code)
USHORT menu_code;
{
USHORT menu, item, sub, next_select;
struct MenuItem *select, *ItemAddress();
while(menu_code != MENUNULL)
{ select = ItemAddress(&Titles[0],menu_code);
menu = MENUNUM(menu_code);
item = ITEMNUM(menu_code);
sub = SUBNUM(menu_code);
switch(menu)
{ case 0: switch(item)
{ case 0: About();
break;
case 1: new();
break;
case 2: ReadBinGadgets(FALSE);
break;
case 3: WriteBinGadgets();
break;
case 4: switch(sub)
{ case 0: WriteCGadgets();
break;
case 1: WriteAsmGadgets();
break;
}
break;
case 5: preferences();
break;
case 6: if(WORKBENCH == TRUE)
{ if((WORKBENCH = (BOOL)OpenWorkBench()))
{ strcpy((char *)&wbb,"Close WorkBench");
ScreenToFront(MainScreen);
}
else Error("Can't open WorkBench !");
}
else
{ if((WORKBENCH = CloseWorkBench()))
strcpy((char *)&wbb,"Open WorkBench");
else Error("Can't close WorkBench !");
}
break;
case 7: quit();
break;
break;
}
break;
case 1: switch(item)
{ case 0: move_gadget();
break;
case 1: size_gadget();
break;
case 2: copy_gadget();
break;
case 3: delete();
break;
case 4: edit();
break;
case 5: switch(sub)
{ case 0: add_text(0);
break;
case 1: modify(0);
break;
case 2: text_delete(0);
break;
case 3: move_text(0);
break;
}
break;
case 6: switch(sub)
{ case 0: render();
break;
case 1: sel_render();
break;
case 2: delete_images();
break;
}
break;
case 7: do_cmap();
break;
case 8: disable_window();
SetPalette(10,20,MainScreen);
enable_window();
break;
case 9: refresh();
break;
case 10: switch(sub)
{ case 0: if(REQUESTER == FALSE) set_flags();
else { BackFill = BackPen; refresh(); }
break;
case 1: if(REQUESTER == FALSE) idcmp();
else add_text(2);
break;
case 2: if(REQUESTER == FALSE) add_text(1);
else modify(2);
break;
case 3: if(REQUESTER == FALSE) modify(1);
else text_delete(2);
break;
case 4: if(REQUESTER == FALSE) text_delete(1);
else move_text(2);
break;
case 5: move_text(1);
break;
}
break;
}
break;
case 2: FrontPen = (USHORT)item; break;
case 3: BackPen = (USHORT)item; break;
default: break;
}
menu_code = select->NextSelect;
}
}
/*
* handle the keyboard events
*/
VOID handle_keys(key_code,qualifier)
USHORT key_code, qualifier;
{
if((key_code & IECODE_UP_PREFIX) != IECODE_UP_PREFIX)
{ switch(qualifier)
{ case IEQUALIFIER_RELATIVEMOUSE:
case IEQUALIFIER_RELATIVEMOUSE+IEQUALIFIER_CAPSLOCK:
switch(key_code)
{ case F1: move_gadget();
break;
case F2: size_gadget();
break;
case F3: copy_gadget();
break;
case F4: delete();
break;
case F5: edit();
break;
case F6: add_text(0);
break;
case F7: render();
break;
case F8: sel_render();
break;
case F9: if(NOT WBSCREEN) do_cmap();
break;
case F10: if(NOT WBSCREEN)
{ disable_window();
SetPalette(10,20,MainScreen);
enable_window();
}
break;
case HELP: refresh();
break;
}
break;
}
}
}